/**
 * 菜单路由
 * 定义与菜单相关的API路由
 */
import { Router } from 'express';
import MenuController from '../controllers/menu.controller.js';
import {
  createMenuValidator,
  updateMenuValidator,
  menuIdValidator,
  roleIdValidator,
  menuQueryValidator
} from '../validators/menu.validator.js';

const router = Router();

// 获取菜单树
router.get('/tree', menuQueryValidator, MenuController.getMenuTree);

// 获取用户菜单（根据角色ID）
router.get('/user/:roleId', roleIdValidator, MenuController.getUserMenus);

// 获取菜单详情
router.get('/:id', menuIdValidator, MenuController.getMenuDetail);

// 创建菜单
router.post('/', createMenuValidator, MenuController.createMenu);

// 更新菜单
router.put('/:id', updateMenuValidator, MenuController.updateMenu);

// 删除菜单
router.delete('/:id', menuIdValidator, MenuController.deleteMenu);

export default router;